package main

import (
	"github.com/gin-gonic/gin"
	"time"
)

// 防止超时中间件
// 可以按时kill掉请求
func TimeOutKill(timeOutTime time.Duration) func(ctx *gin.Context) {
	return func(ctx *gin.Context) {
		go func() {
			time.Sleep(timeOutTime)
			ctx.Abort()
		}()
		ctx.Next()
	}
}
